linux系统安装yarn,centos安装yarn |
您所在的位置:网站首页 › linux node离线安装 › linux系统安装yarn,centos安装yarn |
Yarn是一个用于node.js应用程序的高级包管理软件。它是任意一个其他Nodejs包管理器的快速、安全和可靠的替代方案,比npm更好的解决包依赖问题。本篇文章介绍在CentOS,Redhat和Fedora系统上安装Yarn的方法。 1、使用NPM安装Yarn Yarn组件可与NPM一起安装。只需运行以下命令即可全局安装Yarn。另外,没有-g,就是仅为当前项目安装。$ sudo npm install yarn -g 2、用脚本安装Yarn 这是安装Yarn最为推荐的方法。这将下载yarn档案并在home的.yarn目录下提取。脚本还设置了PATH环境变量。$ curl -o- -L https://yarnpkg.com/install.sh | bash 使用此安装Yarn仅适用于当前用户。 3、使用yum安装Yarn Yum Package Manager也提供Yarn安装包。可以使用以下命令配置yarn官方yum存储库:$ curl -sL https://dl.yarnpkg.com/rpm/yarn.repo -o /etc/yum.repos.d/yarn.repo 现在运行下面的命令来安装它。$ sudo yum install yarn ## CentOS and Redhat systems $ sudo dnf install yarn ## Fedora systems 可能会遇到的问题:[root@host ~]# curl -sL https://dl.yarnpkg.com/rpm/yarn.repo -o /etc/yum.repos.d/yarn.repo [root@host ~]# yum install yarn 已加载插件:fastestmirror 设置安装进程 Loading mirror speeds from cached hostfile * base: mirror.fileplanet.com * elrepo-kernel: repos.lax-noc.com * extras: repos-lax.psychz.net * updates: mirror.fileplanet.com yarn | 2.9 kB 00:00 ... yarn/primary_db | 22 kB 00:00 解决依赖关系 --> 执行事务检查 ---> Package yarn.noarch 0:1.22.4-1 will be 安装 --> 处理依赖关系 nodejs,它被软件包 yarn-1.22.4-1.noarch 需要 --> 完成依赖关系计算 错误:Package: yarn-1.22.4-1.noarch (yarn) Requires: nodejs You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigestYarn requires Node.js 4.0 or higher to be installed. > Yarn was installed, but doesn't seem to be working :(. 这两种提示都是没有安装node,需要先安装nodejs。 下载wget https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.xz 解压遇到问题[root@host ~]# tar -xvf node-v12.16.1-linux-x64.tar.xz tar (child): xz:无法 exec: 没有那个文件或目录 tar (child): Error is not recoverable: exiting now tar: Child returned status 2 tar: Error is not recoverable: exiting now 安装xz可以解决yum install xz 解压并安装[root@host ~]# tar -xvf node-v12.16.1-linux-x64.tar.xz [root@host ~]# cd node-v12.16.1-linux-x64 [root@host node-v12.16.1-linux-x64]# mkdir /usr/local/nodejs [root@host node-v12.16.1-linux-x64]# mv * /usr/local/nodejs/ 安装npm和nodeln -s /usr/local/nodejs/bin/npm /usr/local/bin/ ln -s /usr/local/nodejs/bin/node /usr/local/bin/ 测试npm -v[root@host bin]# npm -v /usr/local/bin/node: /usr/local/bin/node: cannot execute binary file 这是为啥,原来是服务器配置低装的32bit系统不能运行64bit的包,或者你可能是反过来,重新下对应的包即可。可是node没有32位,只好换操作系统。 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |